package com.example.gymmanagebackend.controller;

import com.example.gymmanagebackend.pojo.Evaluate;
import com.example.gymmanagebackend.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/evaluate")
public class EvaluateController {

    @Autowired
    private EvaluateService evaluateService;

    @PostMapping("/add")
    public String addEvaluate(@RequestBody Evaluate evaluate) {
        int result = evaluateService.addEvaluate(evaluate);
        return result > 0 ? "添加成功" : "添加失败";
    }

    @GetMapping("/all")
    public List<Evaluate> getAllEvaluates() {
        return evaluateService.getAllEvaluates();
    }

    @DeleteMapping("/delete/{id}")
    public String deleteEvaluateById(@PathVariable int id) {
        int result = evaluateService.deleteEvaluateById(id);
        return result > 0 ? "删除成功" : "删除失败";
    }

    @PostMapping("/update")
    public String updateEvaluate(@RequestBody Evaluate evaluate) {
        int result = evaluateService.updateEvaluate(evaluate);
        return result > 0 ? "更新成功" : "更新失败";
    }


}
